<{include file="public/header.html"}>

<style>
body { margin:2px;padding:2px; font:normal 14px 宋体, Arial, Helvetica, sans-serif;}

.x-panel-body { background: url("<{$VIRT_IMAGES}>/pub/bk.jpg"); font: 14px 宋体, Arial, Helvetica, sans-serif;}

.firstmenu  {margin:0;position:relative;}
.menulist   {margin:0;list-style-type:none;}
.menulist li {padding-top:5px;height:22px;background:url("<{$VIRT_IMAGES}>/pub/title-bg.gif") left bottom repeat-x;}
.menulist li a {font:13px 宋体, arial;text-decoration:none;color:#00008B;padding:2px 2px 0px 2px; }
.menulist li a:hover {background:url("<{$VIRT_IMAGES}>/pub/b_slider.gif") left bottom repeat-x;color:#00B5F7;}

<{ section name="menu1" loop=$firstMenu }>
<{ if $firstMenu[menu1].IMAGESRC neq "" }>
.bar_<{ $firstMenu[menu1].MENUCODE }> {background-image: url('<{ $firstMenu[menu1].IMAGESRC }>') !important;color:#15428b;}
<{ /if }>
<{ /section }>

</style>

<div id="header">
    Good project for you, 在线项目管理系统 <br/><br/>

    &nbsp; <{$sUserName}>，欢迎您登录系统。<div id="btnExitSystem"></div>
</div>

<div id="mainMenu" >
<{strip}>
<{ section name="menu1" loop=$firstMenu }>
<{ assign var="rowNumb" value="1" }>
<div id="menu_<{ $firstMenu[menu1].MENUCODE }>" class="firstmenu">
    <ul class="menulist">
    <{ section name="menu2" loop=$secondMenu }>
        <{ if $firstMenu[menu1].MENUCODE eq $secondMenu[menu2].UPMENUCODE }>
<li>&nbsp;<{ $rowNumb }>.<a href="#" onclick="openTab('<{ $secondMenu[menu2].MENUCODE }>','<{ $secondMenu[menu2].MENUNAME }>','<{$secondMenu[menu2].URL}>');" title="<{ $secondMenu[menu2].TIP }>"><{ $secondMenu[menu2].MENUNAME }></a></li>
            <{ eval var=$rowNumb+1 assign="rowNumb" }>
        <{ /if }>
    <{ /section }>
    </ul>
</div>
<{ /section }>
<{/strip}>
</div>

<script language="javascript">
<!--
Ext.ux.TabRightMenu = function(){
    var tabs, menu, ctxItem;
    this.init = function(tp){
        tabs = tp;
        tabs.on('contextmenu', onContextMenu);
    }

    function onContextMenu(ts, item, e){
        if (!menu) { // create context menu on first right click
            menu = new Ext.menu.Menu([{
                id: tabs.id + '-reload',
                text: '刷新',
                icon: '<{$VIRT_IMAGES}>/btn/refresh.gif',
                handler : function(){
                    if (ctxItem.id == "tab-homepage") {
                        ctxItem.getUpdater().refresh();
                    } else {
                        var iframeID = ctxItem.id.replace("tab","if");
                        var frame = Ext.getDom(iframeID);
                        if (frame != null) frame.src = frame.src;
                    }
                }
            },'-',{
                id: tabs.id + '-close',
                text: '关闭',
                icon: '<{$VIRT_IMAGES}>/btn/close.gif',
                handler : function(){
                    if (ctxItem.id != "tab-homepage") tabs.remove(ctxItem);
                }
            },{
                id: tabs.id + '-close-others',
                text: '关闭其他',
                handler : function(){
                    tabs.items.each(function(item){
                        if (item.closable && item != ctxItem){
                            tabs.remove(item);
                        }
                    });
                }
            }]);
        }
        ctxItem = item;
        menu.items.get(tabs.id + '-close').setDisabled(!item.closable);
        var disableOthers = true;
        tabs.items.each(function(){
            if(this != item && this.closable){
                disableOthers = false;
                return false;
            }
        });
        menu.items.get(tabs.id + '-close-others').setDisabled(disableOthers);
        menu.showAt(e.getPoint());
    }
};

function openTab(menuCode,tabTitle,tabUrl) {
    tabUrl = '<{$WWWROOT}>/apps/'+tabUrl;
    var tabItem = tabSets.findById("tab-"+menuCode);
    if (tabItem==null) {
        tabItem = tabSets.add({id:"tab-"+menuCode, title:tabTitle,closable:true,
            html: '<iframe id="if-'+menuCode+'" src="'+tabUrl+'" width="100%" height="100%" frameborder="0"/>'});
    }
    tabItem.show();
}

var northPanel = new Ext.Panel({
    region:'north',
    contentEl: 'header',
    height:70,
    split:true,
    minSize:50,
    maxSize:100,
    collapsible:true,
    collapseMode:'mini'
});

var btnExit = new Ext.Button({
    text: '退出系统',
    handler:function() {
        Ext.MessageBox.confirm('确认', '确定要退出系统？', function (btn) {
            if (btn == "yes") { window.close(); }
        }); },
    icon: '<{$VIRT_IMAGES}>/btn/exit.gif',
    cls:"x-btn-text-icon"
});

var westPanel = new Ext.Panel({
    title:'功能菜单',
    layout:'accordion',
    region:'west',
    width:160,
    split:true,
    minSize:80,
    maxSize:220,
    collapsible:true,
    collapseMode:'mini',
    layoutConfig:{animate:true},
    buttonAlign:'center',
    buttons:[btnExit],
    items:[
<{ section name="menu1" loop=$firstMenu }>
    {title:"<{ $firstMenu[menu1].MENUNAME }>",border:false,autoScroll:true,iconCls:'bar_<{ $firstMenu[menu1].MENUCODE }>',contentEl:"menu_<{ $firstMenu[menu1].MENUCODE }>"}
    <{ if $smarty.section.menu1.index+1 < $smarty.section.menu1.max }>,<{ /if }>
<{ /section }>
    ]
});

var tabSets = new Ext.TabPanel({
    id:'tabset',
    region:'center',
    resizeTabs:true, // turn on tab resizing
    minTabWidth:100,
    tabWidth:120,
    activeTab:0,
    enableTabScroll:true,
    defaults: {autoScroll:true},
    plugins: new Ext.ux.TabRightMenu(),
    items:[{title:"首页",id:"tab-homepage",closable:false,
        autoLoad:"<{$WWWROOT}>/apps/member/main.php"}]
});

var mainPanel = new Ext.Viewport({
    renderTo:Ext.getBody(),
    layout:'border',
    margins:'1 1 1 1',
    items:[northPanel,westPanel,tabSets]
});

//-->
</script>

</body>
</html>
